import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ulearning_app/common/widgets/text_widgets.dart';
import 'package:ulearning_app/common/widgets/app_shadow.dart';

Widget appOnboardingPage(PageController controller,
    {String imaagePath = "assets/images/reading.png",
    String title = "",
    String subTitle = "",
    int index = 0,
    context}) {
  return Column(
    children: [
      Image.asset(imaagePath, fit: BoxFit.fitWidth),
      Container(
        margin: EdgeInsets.only(top: 15.h),
        child: text24Normal(text: title),
      ),
      Container(
        margin: EdgeInsets.only(top: 15.h),
        padding: EdgeInsets.only(left: 20.w, right: 20.w),
        child: text16Normal(text: subTitle),
      ),
      _nextButton(index, controller, context)
    ],
  );
}

Widget _nextButton(index, PageController controller, BuildContext context) {
  return GestureDetector(
    onTap: () {
      if (index < 3) {
        controller.animateToPage(index,
            duration: const Duration(milliseconds: 300), curve: Curves.linear);
      } else {
        // Navigator.push<void>(
        //   context,
        //   MaterialPageRoute<void>(
        //     builder: (BuildContext context) => const SignIn(),
        //   ),
        // );
        Navigator.pushNamed(context, '/sign_in');
      }
    },
    child: Container(
      width: 325.w,
      height: 50.h,
      margin: EdgeInsets.only(top: 50.h, left: 25.w, right: 25.w),
      decoration: appBoxShadow(),
      child: Center(
        child:
            text16Normal(text: index < 3 ? "下一步" : "开始", color: Colors.white),
      ),
    ),
  );
}
